package com.cxy.common.request;

import android.util.ArrayMap;

import com.fy.baselibrary.retrofit.converter.html.HtmlBodyType;
import com.fy.baselibrary.retrofit.load.up.UpLoadFileType;

import org.jsoup.nodes.Document;

import java.util.Map;

import io.reactivex.Observable;
import kotlin.jvm.JvmSuppressWildcards;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.QueryMap;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

/**
 * api接口
 * Created by fangs on 2017/8/28.
 */
public interface ApiService {

    //普通get 请求
    @GET
    Observable<BeanModule<Object>> getCompose(@Url String apiUrl, @QueryMap ArrayMap<String, Object> params);

    //普通post 请求【请求参数 json格式 】
    @POST
    Observable<BeanModule<Object>> postCompose(@Url String apiUrl, @Body ArrayMap<String, Object> params);

    //普通post 请求【表单提交】
    @FormUrlEncoded
    @POST
    Observable<BeanModule<Object>> postFormCompose(@Url String apiUrl, @FieldMap ArrayMap<String, Object> params);

    /**
     * 多图片上传 之 图文上传
     */
    @UpLoadFileType
    @POST
    Observable<BeanModule<Object>> uploadFile(@Url String apiUrl, @Body ArrayMap<String, Object> params);

    @Multipart
    @POST("/file/uploadPic")
    Observable<BeanModule<Object>> upload(@PartMap Map<String, RequestBody> params, @Part MultipartBody.Part[] file);

    /**
     * get 请求 返回 HTML格式数据 专用
     * @param apiUrl
     * @param params
     * @return
     */
    @HtmlBodyType
    @GET
    Observable<Document> getHtmlBody(@Url String apiUrl, @QueryMap ArrayMap<String, Object> params);

    @Streaming
    @GET
    Observable<ResponseBody> downloadM3u8(@Url String url);
}
